package top.college.service;

import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;

import javax.swing.JPasswordField;
import javax.swing.JTextField;

import top.college.dao.JDBC_ConnClose;
import top.college.dao.JDBC_SQL;
import top.college.model.AdminVO;

public class AdminUpdate {
	
	public static boolean updateAdmin(JTextField AdminID, JTextField AdminName, 	JPasswordField AdminPW, JTextField AdminTel) {
		AdminVO av = new AdminVO();
		Connection conn = null;
		PreparedStatement pstmt = null;
		ResultSet rs = null;

		try {
			conn = JDBC_ConnClose.openDataBase();
			pstmt = conn.prepareStatement( JDBC_SQL.AdminUpdateSQL );
			pstmt.setString( 1, AdminName.getText() );
			pstmt.setString( 2, AdminPW.getText() );
			pstmt.setString( 3, AdminTel.getText() );
			pstmt.setString( 4, AdminID.getText());
			pstmt.executeUpdate();
			return true;
		} catch ( Exception e ) {
			e.printStackTrace();
		} finally {
			JDBC_ConnClose.closeDataBase(conn, pstmt, rs);
		}
		return false;
	}
}